

import React, { useState, useEffect } from 'react'
import { backgroundObj, navigateTo } from '@/utils/utils'
import { View, Swiper, SwiperItem, Button, Input, Text, Textarea } from '@tarojs/components';
import FixedBtn from "@/components/FormCondition/FixedBtn";
import { fakeSaveHelpQa } from '@/server/shop'
import { toast, goBack } from '@/utils/utils'
import Upload from "@/components/FormCondition/UploadImg";
import './index.scss'
const MutualQuestion = (props) => {
    const [params, setParams] = useState({
        list: [],
        remark: ''
    })
    const {
        list,
        remark
    } = params
    const submit = () => {
        if (!remark) {
            return toast('请填写问题')
        }
        else {
            fakeSaveHelpQa({
                content: JSON.stringify({
                    text: remark,
                    images: list.toString(),

                })
            }).then(val => {
                goBack()
            })
        }
    }
    return <View className='MutualQuestion_box'>
        <View className="MutualQuestion_textArea">
            <View className='MutualQuestion_textArea_changeBox'>
                <Textarea value={remark} onInput={(e) => {
                    setParams({
                        ...params,
                        remark: e.target.value
                    })
                }} placeholder='请填写10字以上的问题描述，有助于帮您快速解决' className='MutualQuestion_textArea_box'>

                </Textarea>
                <View className="MutualQuestion_uploadImage">
                    <Upload list={list} onChange={(e) => {
                        setParams({
                            ...params,
                            list: e
                        })
                    }}></Upload>
                </View>
            </View>

        </View>
        <FixedBtn onClick={(e) => {
            submit()
        }} btnText={'发布回答'}></FixedBtn>
    </View >
}
export default MutualQuestion